
#include "word.h"
#include "lcd.h"

//旭 宽*高 --> 32*38 
unsigned char xu[38][32/8] = 
{  
    /*--  文字:  旭  --*/
    /*--  微软雅黑22;  此字体下对应的点阵为：宽x高=29x38  单位：像素点  --*/
    /*--  宽度不是8的倍数，现调整为：宽度x高度=32x38  --*/
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x1E,0x07,0xFF,0xC0,
    0x1E,0x07,0xFF,0xC0,0x1E,0x07,0xFF,0xC0,0x1E,0x07,0x81,0xC0,0x1E,0x07,0x81,0xC0,
    0xFF,0xF7,0x81,0xC0,0xFF,0xF7,0x81,0xC0,0xFF,0xF7,0x81,0xC0,0x1E,0xF7,0xFF,0xC0,
    0x1E,0xF7,0xFF,0xC0,0x1E,0xF7,0xFF,0xC0,0x1E,0xF7,0x81,0xC0,0x1E,0xF7,0x81,0xC0,
    0x1E,0xF7,0x81,0xC0,0x1E,0xF7,0x81,0xC0,0x1E,0xF7,0x81,0xC0,0x1E,0xF7,0x81,0xC0,
    0x1C,0xF7,0xFF,0xC0,0x1C,0xF7,0xFF,0xC0,0x3C,0xF7,0xFF,0xF0,0x3C,0xF7,0x81,0xF8,
    0x3C,0xF3,0x80,0x38,0x78,0xF0,0x00,0x38,0x78,0x70,0x00,0x78,0xF0,0x7F,0xFF,0xF8,
    0xF0,0x7F,0xFF,0xF0,0x60,0x1F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

};

//三维数组：保存0~9的取模数据
    // number[0] 保存字符0的取模数据
    // number[1] 保存字符1的取模数据
    // ...
    // number[9] 保存字符9的取模数据
unsigned char number[10][46][24/8] = 
{  
/*--  文字:  0  --*/
/*--  微软雅黑26;  此字体下对应的点阵为：宽x高=21x46   --*/
/*--  宽度不是8的倍数，现调整为：宽度x高度=24x46  --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFE,
0x00,0x07,0xFF,0x00,0x0F,0xFF,0x80,0x1F,0x9F,0xC0,0x1F,0x07,0xC0,0x3E,0x07,0xE0,
0x3E,0x03,0xE0,0x3C,0x03,0xE0,0x7C,0x03,0xE0,0x7C,0x01,0xF0,0x7C,0x01,0xF0,0x7C,
0x01,0xF0,0x7C,0x01,0xF0,0x7C,0x01,0xF0,0x7C,0x01,0xF0,0x7C,0x01,0xF0,0x7C,0x01,
0xF0,0x7C,0x01,0xF0,0x7C,0x01,0xE0,0x7C,0x03,0xE0,0x7C,0x03,0xE0,0x3E,0x03,0xE0,
0x3E,0x07,0xC0,0x1F,0x0F,0xC0,0x1F,0xFF,0x80,0x0F,0xFF,0x00,0x07,0xFE,0x00,0x00,
0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  文字:  1  --*/
/*--  微软雅黑26;  此字体下对应的点阵为：宽x高=21x46   --*/
/*--  宽度不是8的倍数，现调整为：宽度x高度=24x46  --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,
0x00,0x00,0x7C,0x00,0x01,0xFC,0x00,0x0F,0xFC,0x00,0x1F,0xFC,0x00,0x1F,0xFC,0x00,
0x1E,0x7C,0x00,0x18,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,
0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,
0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,
0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  文字:  2  --*/
/*--  微软雅黑26;  此字体下对应的点阵为：宽x高=21x46   --*/
/*--  宽度不是8的倍数，现调整为：宽度x高度=24x46  --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFC,
0x00,0x0F,0xFF,0x00,0x1F,0xFF,0x80,0x3F,0x1F,0xC0,0x3C,0x07,0xC0,0x38,0x07,0xC0,
0x00,0x03,0xE0,0x00,0x03,0xE0,0x00,0x03,0xE0,0x00,0x03,0xC0,0x00,0x07,0xC0,0x00,
0x0F,0xC0,0x00,0x0F,0x80,0x00,0x3F,0x00,0x00,0x7E,0x00,0x00,0xFC,0x00,0x03,0xF8,
0x00,0x07,0xF0,0x00,0x0F,0xC0,0x00,0x1F,0x80,0x00,0x1F,0x00,0x00,0x3E,0x00,0x00,
0x3C,0x00,0x00,0x7C,0x00,0x00,0x7F,0xFF,0xE0,0x7F,0xFF,0xE0,0x7F,0xFF,0xE0,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  文字:  3  --*/
/*--  微软雅黑26;  此字体下对应的点阵为：宽x高=21x46   --*/
/*--  宽度不是8的倍数，现调整为：宽度x高度=24x46  --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFC,
0x00,0x1F,0xFE,0x00,0x1F,0xFF,0x00,0x1E,0x1F,0x80,0x18,0x0F,0x80,0x00,0x07,0xC0,
0x00,0x07,0xC0,0x00,0x07,0xC0,0x00,0x07,0xC0,0x00,0x0F,0x80,0x00,0x1F,0x80,0x00,
0xFF,0x00,0x0F,0xFE,0x00,0x0F,0xFE,0x00,0x0F,0xFF,0x00,0x00,0x1F,0x80,0x00,0x0F,
0xC0,0x00,0x07,0xC0,0x00,0x03,0xE0,0x00,0x03,0xE0,0x00,0x03,0xE0,0x00,0x07,0xC0,
0x00,0x07,0xC0,0x38,0x0F,0xC0,0x3F,0xFF,0x80,0x3F,0xFF,0x00,0x3F,0xFE,0x00,0x07,
0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  文字:  4  --*/
/*--  微软雅黑26;  此字体下对应的点阵为：宽x高=21x46   --*/
/*--  宽度不是8的倍数，现调整为：宽度x高度=24x46  --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,
0x00,0x00,0x1F,0x80,0x00,0x1F,0x80,0x00,0x3F,0x80,0x00,0x7F,0x80,0x00,0x7F,0x80,
0x00,0xFF,0x80,0x00,0xFF,0x80,0x01,0xFF,0x80,0x03,0xEF,0x80,0x03,0xCF,0x80,0x07,
0xCF,0x80,0x0F,0x8F,0x80,0x1F,0x0F,0x80,0x1F,0x0F,0x80,0x3E,0x0F,0x80,0x7C,0x0F,
0x80,0xF8,0x0F,0x80,0xFF,0xFF,0xF8,0xFF,0xFF,0xF8,0xFF,0xFF,0xF8,0x00,0x0F,0x80,
0x00,0x0F,0x80,0x00,0x0F,0x80,0x00,0x0F,0x80,0x00,0x0F,0x80,0x00,0x0F,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  文字:  5  --*/
/*--  微软雅黑26;  此字体下对应的点阵为：宽x高=21x46   --*/
/*--  宽度不是8的倍数，现调整为：宽度x高度=24x46  --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFF,
0x80,0x0F,0xFF,0x80,0x1F,0xFF,0x80,0x1F,0xFF,0x80,0x1F,0x00,0x00,0x1F,0x00,0x00,
0x1F,0x00,0x00,0x1F,0x00,0x00,0x1F,0x00,0x00,0x1E,0x00,0x00,0x1E,0xC0,0x00,0x1F,
0xFC,0x00,0x1F,0xFF,0x00,0x1F,0xFF,0x80,0x00,0x1F,0xC0,0x00,0x0F,0xC0,0x00,0x07,
0xC0,0x00,0x03,0xE0,0x00,0x03,0xE0,0x00,0x03,0xE0,0x00,0x03,0xE0,0x00,0x07,0xC0,
0x00,0x07,0xC0,0x38,0x1F,0xC0,0x3F,0xFF,0x80,0x3F,0xFF,0x00,0x3F,0xFE,0x00,0x07,
0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  文字:  6  --*/
/*--  微软雅黑26;  此字体下对应的点阵为：宽x高=21x46   --*/
/*--  宽度不是8的倍数，现调整为：宽度x高度=24x46  --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,
0xC0,0x01,0xFF,0xC0,0x03,0xFF,0xC0,0x07,0xE1,0xC0,0x0F,0xC0,0x00,0x1F,0x80,0x00,
0x1F,0x00,0x00,0x1E,0x00,0x00,0x3E,0x00,0x00,0x3E,0x00,0x00,0x3C,0x7E,0x00,0x3D,
0xFF,0x80,0x7F,0xFF,0xC0,0x7F,0xFF,0xC0,0x7F,0x07,0xE0,0x7E,0x03,0xE0,0x7E,0x01,
0xF0,0x7C,0x01,0xF0,0x7C,0x01,0xF0,0x3C,0x01,0xF0,0x3E,0x01,0xF0,0x3E,0x03,0xE0,
0x1F,0x03,0xE0,0x1F,0x87,0xE0,0x0F,0xFF,0xC0,0x07,0xFF,0x80,0x03,0xFF,0x00,0x00,
0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  文字:  7  --*/
/*--  微软雅黑26;  此字体下对应的点阵为：宽x高=21x46   --*/
/*--  宽度不是8的倍数，现调整为：宽度x高度=24x46  --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,
0xE0,0x7F,0xFF,0xE0,0x7F,0xFF,0xE0,0x7F,0xFF,0xE0,0x00,0x03,0xC0,0x00,0x07,0xC0,
0x00,0x07,0x80,0x00,0x0F,0x80,0x00,0x0F,0x00,0x00,0x1F,0x00,0x00,0x1E,0x00,0x00,
0x3E,0x00,0x00,0x3C,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0xF8,0x00,0x00,0xF8,
0x00,0x00,0xF0,0x00,0x01,0xF0,0x00,0x01,0xF0,0x00,0x03,0xE0,0x00,0x03,0xE0,0x00,
0x03,0xE0,0x00,0x03,0xE0,0x00,0x07,0xC0,0x00,0x07,0xC0,0x00,0x07,0xC0,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  文字:  8  --*/
/*--  微软雅黑26;  此字体下对应的点阵为：宽x高=21x46   --*/
/*--  宽度不是8的倍数，现调整为：宽度x高度=24x46  --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFC,
0x00,0x07,0xFF,0x00,0x0F,0xFF,0x80,0x1F,0x8F,0xC0,0x3F,0x07,0xC0,0x3E,0x03,0xC0,
0x3E,0x03,0xC0,0x3E,0x03,0xC0,0x3E,0x03,0xC0,0x1E,0x07,0xC0,0x1F,0x8F,0x80,0x0F,
0xFF,0x00,0x07,0xFE,0x00,0x0F,0xFF,0x80,0x1F,0xFF,0xC0,0x3F,0x07,0xC0,0x3E,0x03,
0xE0,0x7C,0x01,0xE0,0x7C,0x01,0xF0,0x7C,0x01,0xF0,0x7C,0x01,0xF0,0x7C,0x01,0xE0,
0x7E,0x03,0xE0,0x3F,0x07,0xE0,0x1F,0xFF,0xC0,0x0F,0xFF,0x80,0x07,0xFF,0x00,0x00,
0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

/*--  文字:  9  --*/
/*--  微软雅黑26;  此字体下对应的点阵为：宽x高=21x46   --*/
/*--  宽度不是8的倍数，现调整为：宽度x高度=24x46  --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFC,
0x00,0x0F,0xFF,0x00,0x1F,0xFF,0x80,0x1F,0x9F,0x80,0x3E,0x07,0xC0,0x3E,0x07,0xC0,
0x7C,0x03,0xE0,0x7C,0x03,0xE0,0x7C,0x03,0xE0,0x7C,0x03,0xE0,0x7C,0x03,0xE0,0x7C,
0x03,0xE0,0x3E,0x07,0xE0,0x3F,0x0F,0xE0,0x1F,0xFF,0xE0,0x0F,0xFF,0xE0,0x07,0xFF,
0xE0,0x00,0xE3,0xE0,0x00,0x03,0xE0,0x00,0x03,0xE0,0x00,0x07,0xC0,0x00,0x07,0xC0,
0x00,0x0F,0x80,0x30,0x1F,0x80,0x3F,0xFF,0x00,0x3F,0xFE,0x00,0x3F,0xF8,0x00,0x07,
0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

};



//显示字符 
void show_word( int x0, int y0, int w, int h, unsigned char word[][w/8], int color )
{
    int i,j,k;
    for( i=0; i<h; i++ )
    {
        for( j=0; j<w/8; j++ )
        {
            //解析word[i][j]的每一个bit位（8个bits）
            for( k=7; k>=0; k-- )       //横向取模：高位优先
            {
                //如果该bit位为1，则表示笔画经过这个点 --> 显示颜色
                if( word[i][j] & (1<<k) )   
                {
                    //画点 
                    display_point( j*8+(7-k)+x0, i+y0, color );
                }
            }
        }
    }
}




//显示任意的数字
void show_number( int x0, int y0, int num, int color )
{
    if( num <= 0 )
    {
        show_word( x0, y0, 24, 46, number[0], color );
        return ;
    }

    int m = 0;      //每个字符之间的间隔
    while( num )
    {
        int x = num % 10;       //从 个位 开始显示 

        show_word( x0-m, y0, 24, 46, number[x], color );

        num = num / 10;
        m = m + 24;     //至少要隔开一个字符的宽度
    }
}

